package com.perseygroup.apps;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class PerseyAppActivity extends Activity implements OnClickListener 
{
	Button mAide, mEdt, mStages, mBonsplans, mPreferences, mAbout;
	private final static int MENU_DECONNECTION = 1;
	private final static int MENU_QUITTER = 2;
    
	@Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        mAide = (Button) findViewById(R.id.aide);
        mEdt = (Button) findViewById(R.id.button_edt);
        mStages = (Button) findViewById(R.id.button_stages);
        mBonsplans = (Button) findViewById(R.id.button_bonsplans);
        mPreferences = (Button) findViewById(R.id.button_preferences);
        mAbout = (Button) findViewById(R.id.about);
        
        mAide.setOnClickListener(this);
        mEdt.setOnClickListener(this);
        mStages.setOnClickListener(this);
        mBonsplans.setOnClickListener(this);
        mPreferences.setOnClickListener(this);
        mAbout.setOnClickListener(this);
    }
    
	@Override
	public boolean onCreateOptionsMenu(Menu menu) 
	{
		menu.add(0, MENU_DECONNECTION, Menu.NONE, R.string.text_deconnection).setIcon(R.drawable.deconnexion);
		menu.add(0, MENU_QUITTER, Menu.NONE, R.string.text_quitter).setIcon(R.drawable.quitter);
		return true;
	}
	
	@Override
	public boolean onOptionsItemSelected(MenuItem item) 
	{
		switch (item.getItemId()) 
		{
		case MENU_DECONNECTION:
			//TODO Replace with the intent of authentication activity and erase preferences from memories
			break;
		case MENU_QUITTER:
			finish();
			break;
		default:
			break;
		}
		return true;
	}
	@Override
	public void onClick(View view) 
	{	
		//TODO Implement action which correspond to a button click
	}
}